#!/usr/bin/env python3
# coding: utf-8

import numpy as np
import cv2 as cv
import random
events = [i for i in dir(cv) if 'EVENT' in i]
print(events)

def draw_circle(event,x,y,flags,param):
    if event == cv.EVENT_FLAG_LBUTTON:  # 鼠标按下事件
        print("draw circle")
        len = random.randint(50,150)
        global img
        cv.circle(img,(x,y),len,(len,random.randint(0,255),random.randint(0,255),2))
        cv.imshow('image',img)

img = np.zeros((512,512,3),np.uint8)
cv.namedWindow('image')
cv.setMouseCallback('image',draw_circle)

KEY_ESC = 27
while True:
    # cv.imshow('image',img)
    key = cv.waitKey(0) & 0xff
    if key == KEY_ESC:
        break
cv.destroyAllWindows()
